import 'package:flutter/material.dart';
import '../../helper/routeHelper.dart';
import '../../pages/gmap/gmap.dart';
import '../../pages/gmap/gmap2.dart';
import '../../pages/gmap/gmapHelper.dart';
import '../../widgets/ImgScanCard.dart';
import '../../widgets/inputWidget.dart';
import '../../helper/Helper.dart';

class CleanRecordInfoPage extends StatelessWidget {
  @override
  CleanRecordInfoPage(this.title, this.location, this.img);

  final String title;
  final String location;
  final String img;
  String tm = " ";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text(title),
      ),
      body: CleanRecordBody(context),
    );
  }

  CleanRecordBody(BuildContext context) => SingleChildScrollView(
        child: CleanRecordFields(context),
      );

  Widget imgCard(BuildContext context) {
    return GestureDetector(
        onTap: () {
          if (img != null) {
            RouteHelper.ShowPage(context, ImgScanCard(img));
          }
        },
        child: Container(
            child: new AspectRatio(
              aspectRatio: 1.5 / 1.0,
              child: Helper.Base64ToImage(img),
            ),
            margin: new EdgeInsets.only(top: 6.0, bottom: 8.0),
            alignment: Alignment.topLeft));
  }

  List<Widget> getWidgetList(BuildContext context) {
    List<Widget> list1 = <Widget>[];
    List<Widget> list3 = <Widget>[];
    List<Widget> list4 = <Widget>[];

    List<Widget> list5 = <Widget>[];

    list3.add(InputWidget.getInfo("坐标登记", tm));
    list3.add(InputWidget.getDivider());

    if (location.length > 2) {
      var p1 = GMapHelper.getLocation(location);
      list3.add(Container(
          height: 300.0,
          child: MyMap2(
            location: p1,
            layers: [GMapHelper.MyMarker(p1)],
            zoom: 16.0,
          )));
    }

    list4.add(InputWidget.getInfo("照片登记", tm));
//  list4.add(InputWidget.getDivider());
//  list4.add(
//    Text("注意：拍摄照片须能看出车辆已装满，同时包含车牌信息。",style: TextStyle(color:Colors.red),));
    list4.add(InputWidget.getDivider());
    list4.add(imgCard(context));

    list1.add(InputWidget.inCard2(list3));
    list1.add(InputWidget.inCard2(list4));

    list1.add(InputWidget.inCard2(list5));

    return list1;
  }

  CleanRecordFields(BuildContext context) => Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: getWidgetList(context),
        ),
      );
}
